{% extends 'generic/object_retrieve.html' %}
{% load helpers %}
{% load ui_framework %}

{% block breadcrumbs_wrapper %}{% render_breadcrumbs %}{% endblock breadcrumbs_wrapper %}

{% block header %}{% endblock header %}

{% block content %}

    <div class="row d-print-none mb-16">
        <div class="col-lg-12">
            <div class="float-end d-print-none">
                {% block buttons %}
                    {% if app_data.home_url %}
                        <a href="{% url app_data.home_url %}" class="btn btn-primary">
                            <span class="mdi mdi-home"></span> App Home
                        </a>
                    {% endif %}
                    {% if app_data.config_url %}
                        <a href="{% url app_data.config_url %}" class="btn btn-warning">
                            <span class="mdi mdi-cog"></span> App Configuration
                        </a>
                    {% endif %}
                    {% if app_data.docs_url %}
                        <a href="{% url app_data.docs_url %}" class="btn btn-info">
                            <span class="mdi mdi-cog"></span> App Documentation
                        </a>
                    {% endif %}
                {% endblock buttons %}
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-6">
            {% block content_left_page %}
                <div class="card">
                    <div class="card-header">
                        <strong>App</strong>
                    </div>
                    <table class="table table-hover card-body attr-table">
                        <tr>
                            <td>Package Name</td>
                            <td><code>{{ app_data.package }}</code></td>
                        </tr>
                        <tr>
                            <td>Headline</td>
                            <td>{{ app_data.headline }}</td>
                        </tr>
                        {% if app_data.description and app_data.headline != app_data.description %}
                            <tr>
                                <td>Description</td>
                                <td>{{ app_data.description }}</td>
                            </tr>
                        {% endif %}
                        <tr>
                            <td>Version</td>
                            <td>v{{ app_data.version }}</td>
                        </tr>
                        <tr>
                            <td>By</td>
                            <td>
                                {{ app_data.author | placeholder }}
                                {% if app_data.author_email %}
                                    (<a href="mailto:{{ app_data.author_email }}">{{ app_data.author_email }}</a>)
                                {% endif %}
                            </td>
                        </tr>
                        {% if app_data.availability %}
                            <tr>
                                <td>License</td>
                                <td><label class="badge border border-primary text-primary">{{ app_data.availability }}</label></td>
                            </tr>
                        {% endif %}
                    </table>
                </div>
                <div class="card">
                    <div class="card-header">
                        <strong>Compatibility</strong>
                    </div>
                    <table class="table table-hover card-body attr-table">
                        <tr>
                            <td>Min Nautobot Version</td>
                            <td>{% if object.min_version %}v{{ object.min_version }}{% else %}{{ None|placeholder }}{% endif %}</td>
                        </tr>
                        <tr>
                            <td>Max Nautobot Version</td>
                            <td>{% if object.max_version %}v{{ object.max_version }}{% else %}{{ None|placeholder }}{% endif %}</td>
                        </tr>
                    </table>
                </div>
            {% endblock content_left_page %}
        </div>
        <div class="col-lg-6">
            {% block content_right_page %}
                <div class="card">
                    <div class="card-header">
                        <strong>Features Employed</strong>
                    </div>
                    <table class="table table-hover card-body attr-table">
                        {% with object.features as features %}
                            <tr>
                                <td>Constance Config</td>
                                <td>
                                    {% if features.constance_config %}
                                        <ul class="list-unstyled">
                                            {% for name in features.constance_config %}
                                                {% with options=features.constance_config|get_item:name %}
                                                    <li><code>{{ name | bettertitle }}</code> {{ options.help_text }}</li>
                                                {% endwith %}
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.constance_config %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Data Models</td>
                                <td>
                                    {% if features.models %}
                                        <ul class="list-unstyled">
                                            {% for model_name in features.models %}
                                                <li>{{ model_name | bettertitle }}</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.models %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Data Validators</td>
                                <td>
                                    {% if features.custom_validators %}
                                        <ul class="list-unstyled">
                                            {% for validator in features.custom_validators %}
                                                <li>{{ validator }}</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.custom_validators %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Django Apps</td>
                                <td>
                                    {% if object.installed_apps %}
                                        <ul class="list-unstyled">
                                            {% for app in object.installed_apps %}
                                                <li><code>{{ app }}</code></li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=object.installed_apps %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Git Data</td>
                                <td>
                                    {% if features.datasource_contents %}
                                        <ul class="list-unstyled">
                                            {% for type, dsc in features.datasource_contents %}
                                                {% if type == "extras.gitrepository" %}
                                                    <li><i class = "mdi {{ dsc.icon }}"></i> {{ dsc.name }}</li>
                                                {% endif %}
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.datasource_contents %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Filters</td>
                                <td>
                                    {% if features.filter_extensions %}
                                        {% if features.filter_extensions.filterset_fields %}
                                            <b>FilterSet Filters</b>
                                            <ul class="list-unstyled">
                                                {% for filterset_field in features.filter_extensions.filterset_fields %}
                                                    <li><code>{{ filterset_field }}</code></li>
                                                {% endfor %}
                                            </ul>
                                        {% endif %}
                                        {% if features.filter_extensions.filterform_fields %}
                                            <b>FilterForm Fields</b>
                                            <ul class="list-unstyled">
                                                {% for filterform_field in features.filter_extensions.filterform_fields %}
                                                    <li><code>{{ filterform_field }}</code></li>
                                                {% endfor %}
                                            </ul>
                                        {% endif %}
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.filter_extensions %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Home Page Content</td>
                                <td>{% include 'utilities/render_boolean.html' with value=features.home_page %}</td>
                            </tr>
                            <tr>
                                <td>Jinja Filters</td>
                                <td>{% include 'utilities/render_boolean.html' with value=features.jinja_filters %}</td>
                            </tr>
                            <tr>
                                <td>Jobs</td>
                                <td>
                                    {% if features.jobs %}
                                        <ul class="list-unstyled">
                                            {% for job in features.jobs %}
                                                <li><a href="{% url 'extras:job_run_by_class_path' class_path=job.class_path %}">{{ job }}</a></li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.jobs %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Middleware</td>
                                <td>
                                    {% if object.middleware %}
                                        <ul class="list-unstyled">
                                            {% for middleware in object.middleware %}
                                                <li><code>{{ middleware }}</code></li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=object.middleware %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Nav Menu Items</td>
                                <td>{% include 'utilities/render_boolean.html' with value=features.nav_menu %}</td>
                            </tr>
                            <tr>
                                <td>Page Banner</td>
                                <td>{% include 'utilities/render_boolean.html' with value=features.banner %}</td>
                            </tr>
                            <tr>
                                <td>Page Template Extensions</td>
                                <td>
                                    {% if features.template_extensions %}
                                        <ul class="list-unstyled">
                                            {% for extension in features.template_extensions %}
                                                <li>{{ extension }}</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.template_extensions %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>REST API Endpoints</td>
                                <td>
                                    {% if features.api_urlpatterns %}
                                        <ul class="list-unstyled">
                                            {% for urlpattern in features.api_urlpatterns %}
                                                <li>{{ urlpattern.name | placeholder }} (<code>/api/plugins/{{ object.base_url }}/{{ urlpattern.pattern }}</code>)</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.api_urlpatterns %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Secrets Providers</td>
                                <td>
                                    {% if features.secrets_providers %}
                                        <ul class="list-unstyled">
                                            {% for secrets_provider in features.secrets_providers %}
                                                <li>
                                                    <a href="{% url 'extras:secret_list' %}?provider={{secrets_provider.slug}}">
                                                        {{ secrets_provider.name }}
                                                    </a>
                                                </li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.secrets_providers %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Table Extensions</td>
                                <td>
                                    {% if features.table_extensions %}
                                        {% if features.table_extensions.columns %}
                                            <b>Custom Columns</b>
                                            <ul class="list-unstyled">
                                                {% for column in features.table_extensions.columns %}
                                                    <li><code>{{ column }}</code></li>
                                                {% endfor %}
                                            </ul>
                                        {% endif %}
                                        {% if features.table_extensions.add_to_default_columns %}
                                            <b>Additional Default Columns</b>
                                            <ul class="list-unstyled">
                                                {% for column in features.table_extensions.add_to_default_columns %}
                                                    <li><code>{{ column }}</code></li>
                                                {% endfor %}
                                            </ul>
                                        {% endif %}
                                        {% if features.table_extensions.remove_from_default_columns %}
                                            <b>Remove from Default Columns</b>
                                            <ul class="list-unstyled">
                                                {% for column in features.table_extensions.remove_from_default_columns %}
                                                    <li><code>{{ column }}</code></li>
                                                {% endfor %}
                                            </ul>
                                        {% endif %}
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.table_extensions %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Views/URLs</td>
                                <td>
                                    {% if features.urlpatterns %}
                                        <ul class="list-unstyled">
                                            {% for urlpattern in features.urlpatterns %}
                                                <li>{{ urlpattern.name | placeholder }} (<code>/plugins/{{ object.base_url }}/{{ urlpattern.pattern }}</code>)</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {% include 'utilities/render_boolean.html' with value=features.urlpatterns %}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>Core View Overrides</td>
                                <td>
                                    {% if features.overridden_views %}
                                        <ul class="list-unstyled">
                                            {% for override in features.overridden_views %}
                                                <li>{{ override.0 }} <code>{{ override.1 }}</code></li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {{ False | render_boolean }}
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <td>App Metrics</td>
                                <td>
                                    {% if features.metrics %}
                                        <ul class="list-unstyled">
                                            {% for metric in features.metrics %}
                                                <li><code>{{ metric }}</code></li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        {{ False | render_boolean }}
                                    {% endif %}
                                </td>
                            </tr>
                        {% endwith %}
                    </table>
                </div>
            {% endblock content_right_page %}
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            {% block content_full_width_page %}
            {% endblock content_full_width_page %}
        </div>
    </div>
{% endblock content %}
